import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/gold_price_model.dart';

GoldPriceModel $GoldPriceModelFromJson(Map<String, dynamic> json) {
  final GoldPriceModel goldPriceModel = GoldPriceModel();
  final int? success = jsonConvert.convert<int>(json['success']);
  if (success != null) {
    goldPriceModel.success = success;
  }
  final int? msgid = jsonConvert.convert<int>(json['msgid']);
  if (msgid != null) {
    goldPriceModel.msgid = msgid;
  }
  final GoldPriceResult? result = jsonConvert.convert<GoldPriceResult>(json['result']);
  if (result != null) {
    goldPriceModel.result = result;
  }
  return goldPriceModel;
}

Map<String, dynamic> $GoldPriceModelToJson(GoldPriceModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['success'] = entity.success;
  data['msgid'] = entity.msgid;
  data['result'] = entity.result?.toJson();
  return data;
}

extension GoldPriceModelExtension on GoldPriceModel {
  GoldPriceModel copyWith({
    int? success,
    int? msgid,
    GoldPriceResult? result,
  }) {
    return GoldPriceModel()
      ..success = success ?? this.success
      ..msgid = msgid ?? this.msgid
      ..result = result ?? this.result;
  }
}

GoldPriceResult $GoldPriceResultFromJson(Map<String, dynamic> json) {
  final GoldPriceResult goldPriceResult = GoldPriceResult();
  final String? dtQuery = jsonConvert.convert<String>(json['dtQuery']);
  if (dtQuery != null) {
    goldPriceResult.dtQuery = dtQuery;
  }
  final String? dtCount = jsonConvert.convert<String>(json['dtCount']);
  if (dtCount != null) {
    goldPriceResult.dtCount = dtCount;
  }
  final Map<String, GoldPriceResultDt>? dtList =
  (json['dtList'] as Map<String, dynamic>?)?.map(
          (k, e) => MapEntry(k, jsonConvert.convert<GoldPriceResultDt>(e) as GoldPriceResultDt));
  if (dtList != null) {
    goldPriceResult.dtList = dtList;
  }
  return goldPriceResult;
}

Map<String, dynamic> $GoldPriceResultToJson(GoldPriceResult entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['dtQuery'] = entity.dtQuery;
  data['dtCount'] = entity.dtCount;
  data['dtList'] = entity.dtList;
  return data;
}

extension GoldPriceResultExtension on GoldPriceResult {
  GoldPriceResult copyWith({
    String? dtQuery,
    String? dtCount,
    Map<String, GoldPriceResultDt>? dtList,
  }) {
    return GoldPriceResult()
      ..dtQuery = dtQuery ?? this.dtQuery
      ..dtCount = dtCount ?? this.dtCount
      ..dtList = dtList ?? this.dtList;
  }
}

GoldPriceResultDt $GoldPriceResultDtFromJson(Map<String, dynamic> json) {
  final GoldPriceResultDt goldPriceResultDt = GoldPriceResultDt();
  final String? goldid = jsonConvert.convert<String>(json['goldid']);
  if (goldid != null) {
    goldPriceResultDt.goldid = goldid;
  }
  final String? variety = jsonConvert.convert<String>(json['variety']);
  if (variety != null) {
    goldPriceResultDt.variety = variety;
  }
  final String? varietynm = jsonConvert.convert<String>(json['varietynm']);
  if (varietynm != null) {
    goldPriceResultDt.varietynm = varietynm;
  }
  final String? lastPrice = jsonConvert.convert<String>(json['last_price']);
  if (lastPrice != null) {
    goldPriceResultDt.lastPrice = lastPrice;
  }
  final String? buyPrice = jsonConvert.convert<String>(json['buy_price']);
  if (buyPrice != null) {
    goldPriceResultDt.buyPrice = buyPrice;
  }
  final String? sellPrice = jsonConvert.convert<String>(json['sell_price']);
  if (sellPrice != null) {
    goldPriceResultDt.sellPrice = sellPrice;
  }
  final String? openPrice = jsonConvert.convert<String>(json['open_price']);
  if (openPrice != null) {
    goldPriceResultDt.openPrice = openPrice;
  }
  final String? yesyPrice = jsonConvert.convert<String>(json['yesy_price']);
  if (yesyPrice != null) {
    goldPriceResultDt.yesyPrice = yesyPrice;
  }
  final String? highPrice = jsonConvert.convert<String>(json['high_price']);
  if (highPrice != null) {
    goldPriceResultDt.highPrice = highPrice;
  }
  final String? lowPrice = jsonConvert.convert<String>(json['low_price']);
  if (lowPrice != null) {
    goldPriceResultDt.lowPrice = lowPrice;
  }
  final String? changePrice = jsonConvert.convert<String>(json['change_price']);
  if (changePrice != null) {
    goldPriceResultDt.changePrice = changePrice;
  }
  final String? changeMargin = jsonConvert.convert<String>(json['change_margin']);
  if (changeMargin != null) {
    goldPriceResultDt.changeMargin = changeMargin;
  }
  final String? uptime = jsonConvert.convert<String>(json['uptime']);
  if (uptime != null) {
    goldPriceResultDt.uptime = uptime;
  }
  return goldPriceResultDt;
}

Map<String, dynamic> $GoldPriceResultDtToJson(GoldPriceResultDt entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['goldid'] = entity.goldid;
  data['variety'] = entity.variety;
  data['varietynm'] = entity.varietynm;
  data['last_price'] = entity.lastPrice;
  data['buy_price'] = entity.buyPrice;
  data['sell_price'] = entity.sellPrice;
  data['open_price'] = entity.openPrice;
  data['yesy_price'] = entity.yesyPrice;
  data['high_price'] = entity.highPrice;
  data['low_price'] = entity.lowPrice;
  data['change_price'] = entity.changePrice;
  data['change_margin'] = entity.changeMargin;
  data['uptime'] = entity.uptime;
  return data;
}

extension GoldPriceResultDtExtension on GoldPriceResultDt {
  GoldPriceResultDt copyWith({
    String? goldid,
    String? variety,
    String? varietynm,
    String? lastPrice,
    String? buyPrice,
    String? sellPrice,
    String? openPrice,
    String? yesyPrice,
    String? highPrice,
    String? lowPrice,
    String? changePrice,
    String? changeMargin,
    String? uptime,
  }) {
    return GoldPriceResultDt()
      ..goldid = goldid ?? this.goldid
      ..variety = variety ?? this.variety
      ..varietynm = varietynm ?? this.varietynm
      ..lastPrice = lastPrice ?? this.lastPrice
      ..buyPrice = buyPrice ?? this.buyPrice
      ..sellPrice = sellPrice ?? this.sellPrice
      ..openPrice = openPrice ?? this.openPrice
      ..yesyPrice = yesyPrice ?? this.yesyPrice
      ..highPrice = highPrice ?? this.highPrice
      ..lowPrice = lowPrice ?? this.lowPrice
      ..changePrice = changePrice ?? this.changePrice
      ..changeMargin = changeMargin ?? this.changeMargin
      ..uptime = uptime ?? this.uptime;
  }
}